package mysql

import "gorm.io/gorm"

type Order struct {
	gorm.Model
	GoodId  int    `gorm:"type:int(5);comment:商品id"`
	GoodNum int    `gorm:"type:int(5);comment:商品数量"`
	Amount  int64  `gorm:"type:int(10);comment:订单总价"`
	OrderSn string `gorm:"type:varchar(100);comment:订单编号"`
	PayType int    `gorm:"type:int(3);comment:支付类型"`
}

type OrderGood struct {
	gorm.Model
	UserId     int    `gorm:"type:int(6);comment:用户id"`
	OrderId    int    `gorm:"type:int(6);comment:订单id"`
	GoodTitle  string `gorm:"type:varchar(100);comment:商品标题"`
	GoodPrice  int64  `gorm:"type:int(6);comment:商品价格"`
	GoodStock  int64  `gorm:"type:int(5);comment:商品库存"`
	GoodCover  string `gorm:"type:varchar(100);comment:商品状态"`
	GoodStatus int64  `gorm:"type:int(2);default:0;comment:商品状态"`
}

func (O *Order) OrderCreate() error {
	return db.Create(&O).Error
}
func (og *OrderGood) OrderGoodCreate() error {
	return db.Create(&og).Error
}
